package Count;

import java.util.HashSet;

//从键盘输入一个字符串s1，由于有些键坏了，只输出了s2,判断有哪些键是坏的
public class KeyBround {
    public static void KeyBad(String s1,String s2){
        HashSet<Character> set=new HashSet<>();
        for(int i=0;i<s2.length();i++){
            set.add(s2.charAt(i));//在集合中保留可打出的字符
        }
        HashSet<Character> set2=new HashSet<>();

        System.out.println("坏掉的键为：");
        for(int i=0;i<s1.length();i++){
            if(!set.contains(s1.charAt(i))&&!set2.contains(s1.charAt(i))){//不重复的放入坏键
                set2.add(s1.charAt(i));
                System.out.print(s1.charAt(i)+" ");
            }
        }
    }
        public static void main(String[] args){
            String s1="the world me love";
            String s2="e word me ove";
            KeyBad(s1,s2);
        }
}
